﻿$(document).ready(function () {
    //forbidKey();
});
/********--------******** 工具方法 ********--------********/
String.prototype.replaceAll = function (reallyDo, replaceWith) {
    var tempStr = this;
    while (tempStr.indexOf(reallyDo) >= 0) {
        tempStr = tempStr.replace(reallyDo, replaceWith);
    }
    return tempStr;
}
/*
 * convertStr2Json
 *
 */
function convertStr2Json(strJsonValue) {
    try {
        return eval(strJsonValue);
    } catch (e) {
        return eval("(" + strJsonValue + ")");
    }
}
/*
 * convertJson2Str
 *
 */
function convertJson2Str(jsonObj) {
    return JSON.stringify(jsonObj);
}
/*
 * conver2StrIfNull
 *
 */
function conver2StrIfNull(fromValue) {
    if (null == fromValue || fromValue == "undefined") {
        return "";
    } else {
        return fromValue;
    }
}
/*
 * writeLog 
 *
 */
function writeLog(e, logMsg) {
    if (console != null) {
        console.log(logMsg + "  Error : " + e.message);
    }
}
/*
 * isEmpty 
 *
 */
function isEmpty(value) {
    if (null == value || "undefined" == value || value.length == 0) {
        return true;
    } else {
        return false;
    }
}
/*
 * 判断数字是否是小数
 *
 */
function isNum(s) {
    var regu = "^([0-9]*[.0-9])$"; // 小数测试
    var re = new RegExp(regu);
    var stri = s + "";
    if (stri.match(re))
        return false;
    else
        return true;
}
/*
 * 引入外部文件
 *
 */
function dynamicLoadingJs(path) {
    if (!path || path.length === 0) {
        throw new Error('argument "path" is required !');
    }
    var head = document.getElementsByTagName('head')[0];
    var script = document.createElement('script');
    script.src = path;
    script.type = 'text/javascript';
    head.appendChild(script);
}
function dynamicLoadingCss(path) {

    if (!path || path.length === 0) {
        throw new Error('argument "path" is required !');
    }
    var head = document.getElementsByTagName('head')[0];
    var link = document.createElement('link');
    link.href = path;
    link.rel = 'stylesheet';
    link.type = 'text/css';
    head.appendChild(link);
}
/*
        * 动态调整iframe的高度
        *
        */
function dyniframesize(frameId) {
    var pTar = null;
    if (document.getElementById) {
        pTar = document.getElementById(frameId);
    }
    else {
        eval('pTar = ' + frameId + ';');
    }
    if (pTar && !window.opera) {
        //begin resizing iframe 
        pTar.style.display = "block"
        if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight) {
            //ns6 syntax 
            pTar.height = pTar.contentDocument.body.offsetHeight + 20;
            pTar.width = pTar.contentDocument.body.scrollWidth + 20;
        }
        else if (pTar.Document && pTar.Document.body.scrollHeight) {
            //ie5+ syntax 
            pTar.height = pTar.Document.body.scrollHeight;
            pTar.width = pTar.Document.body.scrollWidth;
        }
    }
}
function forbidKey() {
    // 屏蔽右键功能
    document.oncontextmenu = function () { return false; }
    // 屏蔽F2-F12功能
    document.onkeydown = function () {
        var forbid = false;
        if (window.event && window.event.keyCode == 113) {
            forbid = true;
        }
        if (window.event && window.event.keyCode == 114) {
            forbid = true;
        }
        if (window.event && window.event.keyCode == 115) {
            forbid = true;
        }
        if (window.event && window.event.keyCode == 116) {
            forbid = true;
        }
        if (window.event && window.event.keyCode == 117) {
            forbid = true;
        }
        if (window.event && window.event.keyCode == 118) {
            forbid = true;
        }
        if (window.event && window.event.keyCode == 119) {
            forbid = true;
        }
        if (window.event && window.event.keyCode == 120) {
            forbid = true;
        }
        if (window.event && window.event.keyCode == 121) {
            forbid = true;
        }
        if (window.event && window.event.keyCode == 122) {
            forbid = true;
        }
        if (window.event && window.event.keyCode == 123) {
            forbid = true;
        }

        if (forbid) {
            window.event.returnValue = false;
        }
    }
}


/*
         * Map对象，实现Map功能
         * size() 获取Map元素个数
         * isEmpty() 判断Map是否为空
         * clear() 删除Map所有元素
         * put(key, value) 向Map中增加元素（key, value)  
         * remove(key) 删除指定key的元素，成功返回true，失败返回false
         * get(key) 获取指定key的元素值value，失败返回null
         * element(index) 获取指定索引的元素（使用element.key，element.value获取key和value），失败返回null
         * containsKey(key) 判断Map中是否含有指定key的元素
         * containsValue(value) 判断Map中是否含有指定value的元素
         * keys() 获取Map中所有key的数组（array）
         * values() 获取Map中所有value的数组（array）
         */
function Map() {
    this.elements = new Array();

    //获取Map元素个数
    this.size = function () {
        return this.elements.length;
    },

    //判断Map是否为空
    this.isEmpty = function () {
        return (this.elements.length < 1);
    },

    //删除Map所有元素
    this.clear = function () {
        this.elements = new Array();
    },
    this.sort = function () {
        this.elements.sort(function (x, y) {
            return x.key > y.key;
        });
    },
    this.sortSmall = function () {
        this.elements.sort(function (x, y) {
            return x.key < y.key;
        });
    },
    this.sortProduct = function () {
        this.elements.sort(function (x, y) {
            return x.key.substring(5) - y.key.substring(5);
        });
    },
     this.sortProductSmall = function () {
         this.elements.sort(function (x, y) {
             return y.key.substring(5) - x.key.substring(5);
         });
     }
    ,
    //向Map中增加元素（key, value)  
    this.put = function (_key, _value) {
        if (this.containsKey(_key) == true) {
            if (this.containsValue(_value)) {
                if (this.remove(_key) == true) {
                    this.elements.push({
                        key: _key,
                        value: _value
                    });
                }
            } else {
                this.elements.push({
                    key: _key,
                    value: _value
                });
            }
        } else {
            this.elements.push({
                key: _key,
                value: _value
            });
        }
    },

    //删除指定key的元素，成功返回true，失败返回false
    this.remove = function (_key) {
        var bln = false;
        try {
            for (i = 0; i < this.elements.length; i++) {
                if (this.elements[i].key == _key) {
                    this.elements.splice(i, 1);
                    return true;
                }
            }
        } catch (e) {
            bln = false;
        }
        return bln;
    },

    //获取指定key的元素值value，失败返回null
    this.get = function (_key) {
        try {
            for (i = 0; i < this.elements.length; i++) {
                if (this.elements[i].key == _key) {
                    return this.elements[i].value;
                }
            }
        } catch (e) {
            return null;
        }
    },

    //获取指定索引的元素（使用element.key，element.value获取key和value），失败返回null
    this.element = function (_index) {
        if (_index < 0 || _index >= this.elements.length) {
            return null;
        }
        return this.elements[_index];
    },

    //判断Map中是否含有指定key的元素
    this.containsKey = function (_key) {
        var bln = false;
        try {
            for (i = 0; i < this.elements.length; i++) {
                if (this.elements[i].key == _key) {
                    bln = true;
                }
            }
        } catch (e) {
            bln = false;
        }
        return bln;
    },

    //判断Map中是否含有指定value的元素
    this.containsValue = function (_value) {
        var bln = false;
        try {
            for (i = 0; i < this.elements.length; i++) {
                if (this.elements[i].value == _value) {
                    bln = true;
                }
            }
        } catch (e) {
            bln = false;
        }
        return bln;
    },

    //获取Map中所有key的数组（array）
    this.keys = function () {
        var arr = new Array();
        for (i = 0; i < this.elements.length; i++) {
            arr.push(this.elements[i].key);
        }
        return arr;
    },

    //获取Map中所有value的数组（array）
    this.values = function () {
        var arr = new Array();
        for (i = 0; i < this.elements.length; i++) {
            arr.push(this.elements[i].value);
        }
        return arr;
    };
}


var setGradient = (function () {
    var p_dCanvas = document.createElement('canvas');
    var p_useCanvas = !!(typeof (p_dCanvas.getContext) == 'function');
    var p_dCtx = p_useCanvas ? p_dCanvas.getContext('2d') : null;
    var p_isIE = /*@cc_on!@*/false;
    try { p_dCtx.canvas.toDataURL() } catch (err) {
        p_useCanvas = false;
    };

    if (p_useCanvas) {
        return function (dEl, sColor1, sColor2, bRepeatY) {
            if (typeof (dEl) == 'string') dEl = document.getElementById(dEl);
            if (!dEl) return false;
            var nW = dEl.offsetWidth;
            var nH = dEl.offsetHeight;
            p_dCanvas.width = nW;
            p_dCanvas.height = nH;
            var dGradient;
            var sRepeat;
            if (bRepeatY) {
                dGradient = p_dCtx.createLinearGradient(0, 0, nW, 0);
                sRepeat = 'repeat-y';
            } else {
                dGradient = p_dCtx.createLinearGradient(0, 0, 0, nH);
                sRepeat = 'repeat-x';
            }

            dGradient.addColorStop(0, sColor1);
            dGradient.addColorStop(1, sColor2);

            p_dCtx.fillStyle = dGradient;
            p_dCtx.fillRect(0, 0, nW, nH);
            var sDataUrl = p_dCtx.canvas.toDataURL('image/png');

            with (dEl.style) {
                backgroundRepeat = sRepeat;
                backgroundImage = 'url(' + sDataUrl + ')';
                backgroundColor = sColor2;
            };
        }
    } else if (p_isIE) {

        p_dCanvas = p_useCanvas = p_dCtx = null;
        return function (dEl, sColor1, sColor2, bRepeatY) {
            if (typeof (dEl) == 'string') dEl = document.getElementById(dEl);
            if (!dEl) return false;
            dEl.style.zoom = 1;
            var sF = dEl.currentStyle.filter;
            dEl.style.filter += ' ' + ['progid:DXImageTransform.Microsoft.gradient(	GradientType=', +(!!bRepeatY), ',enabled=true,startColorstr=', sColor1, ', endColorstr=', sColor2, ')'].join('');
        };

    } else {
        p_dCanvas = p_useCanvas = p_dCtx = null;
        return function (dEl, sColor1, sColor2) {

            if (typeof (dEl) == 'string') dEl = document.getElementById(dEl);
            if (!dEl) return false;
            with (dEl.style) {
                backgroundColor = sColor2;
            };
        }
    }
})();


/*
 HTML5 Shiv v3.6.2pre | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
*/
(function (l, f) {
    function m() { var a = e.elements; return "string" == typeof a ? a.split(" ") : a } function i(a) { var b = n[a[o]]; b || (b = {}, h++, a[o] = h, n[h] = b); return b } function p(a, b, c) { b || (b = f); if (g) return b.createElement(a); c || (c = i(b)); b = c.cache[a] ? c.cache[a].cloneNode() : r.test(a) ? (c.cache[a] = c.createElem(a)).cloneNode() : c.createElem(a); return b.canHaveChildren && !s.test(a) ? c.frag.appendChild(b) : b } function t(a, b) {
        if (!b.cache) b.cache = {}, b.createElem = a.createElement, b.createFrag = a.createDocumentFragment, b.frag = b.createFrag();
        a.createElement = function (c) { return !e.shivMethods ? b.createElem(c) : p(c, a, b) }; a.createDocumentFragment = Function("h,f", "return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&(" + m().join().replace(/\w+/g, function (a) { b.createElem(a); b.frag.createElement(a); return 'c("' + a + '")' }) + ");return n}")(e, b.frag)
    } function q(a) {
        a || (a = f); var b = i(a); if (e.shivCSS && !j && !b.hasCSS) {
            var c, d = a; c = d.createElement("p"); d = d.getElementsByTagName("head")[0] || d.documentElement; c.innerHTML = "x<style>article,aside,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}</style>";
            c = d.insertBefore(c.lastChild, d.firstChild); b.hasCSS = !!c
        } g || t(a, b); return a
    } var k = l.html5 || {}, s = /^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i, r = /^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i, j, o = "_html5shiv", h = 0, n = {}, g; (function () {
        try {
            var a = f.createElement("a"); a.innerHTML = "<xyz></xyz>"; j = "hidden" in a; var b; if (!(b = 1 == a.childNodes.length)) {
                f.createElement("a"); var c = f.createDocumentFragment(); b = "undefined" == typeof c.cloneNode ||
                "undefined" == typeof c.createDocumentFragment || "undefined" == typeof c.createElement
            } g = b
        } catch (d) { g = j = !0 }
    })(); var e = {
        elements: k.elements || "abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup main mark meter nav output progress section summary time video", version: "3.6.2pre", shivCSS: !1 !== k.shivCSS, supportsUnknownElements: g, shivMethods: !1 !== k.shivMethods, type: "default", shivDocument: q, createElement: p, createDocumentFragment: function (a, b) {
            a || (a = f); if (g) return a.createDocumentFragment();
            for (var b = b || i(a), c = b.frag.cloneNode(), d = 0, e = m(), h = e.length; d < h; d++) c.createElement(e[d]); return c
        }
    }; l.html5 = e; q(f)
})(this, document);

